package com.example.back.controller;

import com.example.back.dto.req.DiseaseEditReq;
import com.example.back.dto.req.DiseaseListReq;
import com.example.back.dto.resp.DiseaseInfoRsp;
import com.example.back.dto.resp.DiseaseListResp;
import com.example.back.service.DiseaseService;
import com.example.common.support.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author wxy
 * @Date 2021/1/14 13:32
 * @Version 1.0
 */
@RestController
@Api(tags = "疾病管理")
@RequestMapping("/api/Disease")
public class DiseaseController {
    @Resource
    private DiseaseService diseaseService;

    @ApiOperation(value = "疾病列表", notes = "疾病列表")
    @PostMapping(value = "/List")
    public Result<PageInfo<DiseaseListResp>> List(@RequestBody DiseaseListReq req) {
        return Result.success(diseaseService.List(req));
    }

    @ApiOperation(value = "启用、禁用", notes = "启用、禁用")
    @PostMapping(value = "/DoDisable")
    public Result<Object> DoDisable(@RequestBody DiseaseEditReq req) {
        return Result.success(diseaseService.DoDisable(req));
    }

    @ApiOperation(value = "详情", notes = "详情")
    @PostMapping(value = "/Info")
    public Result<DiseaseInfoRsp> Info(@RequestBody DiseaseEditReq req) {
        return Result.success(diseaseService.Info(req));
    }

    @ApiOperation(value = "编辑和添加疾病", notes = "编辑和添加疾病")
    @PostMapping(value = "/Save")
    public Result<Object> Save(@RequestBody DiseaseEditReq req) {
        return Result.success(diseaseService.Save(req));
    }
}
